package light.mvc.model.books;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import light.mvc.model.base.IdEntity;
import light.mvc.model.sys.Tuser;

import org.hibernate.annotations.OrderBy;

@Entity
@Table(name = "lib_materials")
public class Tmaterial extends IdEntity implements java.io.Serializable {

	private Date createdatetime; // 创建时间
	private String name; // 名称
	private String description; // 描述
	private String icon; // 图标
	private String url; // 路径
	private String state; // 路径
	private Integer seq; // 排序号
	private Integer resourcetype; // 资源类型, 0菜单 1功能
	private Integer size; 
	private Integer materialType;//文档类型：0为文件夹，1为文件
	
	private Tuser builder; // 创建者
	private Tmaterial parent; // 父级
	private Set<Tmaterial> children = new HashSet<Tmaterial>(0);
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public Tuser getBuilder() {
		return builder;
	}

	public Integer getMaterialType() {
		return materialType;
	}


	public void setMaterialType(Integer materialType) {
		this.materialType = materialType;
	}


	public void setBuilder(Tuser builder) {
		this.builder = builder;
	}

	public Tmaterial() {
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATEDATETIME", length = 19)
	public Date getCreatedatetime() {
		return createdatetime;
	}

	public void setCreatedatetime(Date createdatetime) {
		this.createdatetime = createdatetime;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}

	public Integer getResourcetype() {
		return resourcetype;
	}

	public void setResourcetype(Integer resourcetype) {
		this.resourcetype = resourcetype;
	}

	public Integer getSize() {
		return size;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	public Tmaterial getParent() {
		return parent;
	}

	public void setParent(Tmaterial parent) {
		this.parent = parent;
	}

	public void setSize(Integer size) {
		this.size = size;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
	@OrderBy(clause = "id")  
	public Set<Tmaterial> getChildren() {
		return children;
	}

	public void setChildren(Set<Tmaterial> children) {
		this.children = children;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	
	

}